

var http = require('http');
var fs = require('fs');
var url = require('url');

var hostname = '127.0.0.1';
var port = '3000';

var server = http.createServer( function ( req,res ) {
    if ( req.url == '/favicon.ico' ) {return};
    var user = url.parse(req.url).pathname;
    if ( user.substr(0,5) == '/stu/' ) {
        var stuid = user.substr(5);
    res.writeHead(200,{"content-type":"text/html;charset=utf-8"});
    res.end('您查询的学号是'+stuid);
        }else if( user.substr(0,5) == '/tch/' ) {
            var tchid = user.substr(5);
            res.writeHead(200,{"content-type":"text/html;charset=utf-8"});
            res.end('您查询的工号是'+tchid);
    }else{
        fs.readFile('./404.png',function(err,data){
        res.end(data);
    });
    };
});

server.listen(port,hostname);